struct ControllerState
{
public:
    ControllerState()
    {
        state = 0;
    }

    bool operator==(const ControllerState &other) const;
    bool operator<(const ControllerState &other) const;

    UINT state;

    bool left()  const { return ((state & leftBit ) != 0); }
    bool right() const { return ((state & rightBit) != 0); }
    bool up()    const { return ((state & upBit   ) != 0); }
    bool down()  const { return ((state & downBit ) != 0); }
    bool A()     const { return ((state & ABit    ) != 0); }
    bool B()     const { return ((state & BBit    ) != 0); }

    void KeyDown(int key);
    void KeyUp(int key);

    static vector<ControllerState> getAllStates();

    // Get the states {left, right, up, down, nothing}
    static vector<ControllerState> getDirectionStates();

    // Get the states {left, right, nothing}
    static vector<ControllerState> getLeftRightStates();
private:
    int BitFromKey(int key);

    static const int leftBit  = 0x1 << 0;
    static const int rightBit = 0x1 << 1;
    static const int upBit    = 0x1 << 2;
    static const int downBit  = 0x1 << 3;
    static const int ABit     = 0x1 << 4;
    static const int BBit     = 0x1 << 5;
};
